package com.chenpeijian.demo.common;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * @program: student_code
 * @description:
 * @author: 陈培建
 * @create: 2024-12-12 19:20
 **/
public class PhoneValidator implements ConstraintValidator<CustomValidPhone, String> {
    private static final String PHONE_REGEX = "^1[3-9]\\d{9}$";
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        return value != null && value.matches(PHONE_REGEX);
    }
}
